package net.sharpf2.api.world;

import java.awt.Point;

/**
 * 
 * @author Sam Smekens
 */
public class Area {
  private int minX;
  private int minY;
  private int maxX;
  private int maxY;
  
  /**
   * Generates a virtual area with given parameters
   * @param minX Top left x-coordinate
   * @param minY Bottom right y-coordinate
   * @param maxX Bottom right x-coordinate
   * @param maxY Top Left y-coordinate
   */
  public Area(int minX, int minY, int maxX, int maxY) {
    this.minX = minX;
    this.minY = minY;
    this.maxX = maxX;
    this.maxY = maxY;
  }
  
  /**
   * Generates a virtual area with given points
   * @param a   Left-top corner coordinates
   * @param b   Right-bottom corner coordinates
   */
  public Area(Point a, Point b){
    this.minX = a.x;
    this.minY = b.y;
    this.maxX = b.x;
    this.maxY = a.y;
  }
  
  public Point getTopCoordinate(){
      return new Point(minX, maxY);
  }
  
  public Point getBottomCoordinate(){
      return new Point(maxX, minY);
  }

  /**
   * Checks if the area contains the given point
   * @param     point
   * @return    <true> if area contains point, otherwise <false>
   */
  public boolean contains(Point point) {
        return (point.x >= minX && point.x <= maxX) && (point.y >= minY && point.y <= maxY);
  }
}
